var t = require("../../../../@babel/runtime/helpers/defineProperty");

Component({
    properties: {
        steps: {
            type: Number,
            value: 0
        },
        stepsList: {
            type: Array
        }
    },
    data: {
        percent: 50,
        number: -1,
        progressList: [],
        bubbleList: []
    },
    lifetimes: {
        attached: function() {
            this.randomColor(), this.timerAni();
            var t = wx.getStorageSync("backgroundRGB");
            t || (t = [ 254, 196, 0 ]), this.setData({
                backgroundRGB: t
            });
        }
    },
    pageLifetimes: {
        show: function() {
            this.timerAni();
        },
        hide: function() {
            clearInterval(this.timer);
        }
    },
    observers: {
        stepsList: function(t) {
            this.setProgress();
        }
    },
    methods: {
        setProgress: function() {
            var t = this.data.stepsList, e = [], s = 0;
            t.length <= 2 ? this.setData({
                percent: 100
            }) : this.setData({
                percent: 50
            }), t.length <= 3 ? (e = t, s = this.data.steps) : this.data.steps < t.length - 1 && 0 == this.data.steps ? e.push(t[0], t[1], t[t.length - 1]) : this.data.steps < t.length - 1 && this.data.steps > 0 ? (e.push(t[0], t[this.data.steps], t[t.length - 1]), 
            s = 1) : (e.push(t[0], t[Math.round(t.length / 2)], t[t.length - 1]), s = 2), this.setData({
                steps: s,
                progressList: e
            });
        },
        randomNum: function(t, e) {
            switch (arguments.length) {
              case 1:
                return parseInt(Math.random() * t + 1, 10);

              case 2:
                return parseInt(Math.random() * (e - t + 1) + t, 10);

              default:
                return 0;
            }
        },
        randomColor: function() {
            for (var t = "#", e = 0; e < 6; e++) t += (16 * Math.random() | 0).toString(16);
            return {
                color: t
            };
        },
        timerAni: function() {
            for (var e = this, s = 0; s < 8; s++) {
                var a = this.randomColor();
                this.setData(t({}, "bubbleList[".concat(s, "]"), a)), this.data.bubbleList.push(a);
            }
            this.timer = setInterval(function() {
                e.translate();
            }, 1500);
        },
        translate: function() {
            var t = this, e = this.randomNum(-20, 20);
            this.setData({
                number: this.data.number + 1
            }, function() {
                t.data.number > 7 && t.setData({
                    number: -1
                });
            }), this.animate(".active", [ {
                opacity: 1,
                translateY: 0
            }, {
                opacity: 1,
                translate: [ e, this.randomNum(-5, -20) ]
            }, {
                translate: [ e, -200 ]
            } ], 1500, function() {}.bind(this));
        }
    }
});